<#include "copyright.ftl"/>
package ${basePackage}.${moduleName}.web.controller${submoduleName!?replace("\\", ".")};

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import org.apache.ibatis.annotations.Param;
import com.shfft.common.page.Page;
import org.springframework.ui.Model;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import ${basePackage}.${moduleName}.domain${submoduleName!?replace("\\", ".")}.${table.tableAlias};
import ${basePackage}.${moduleName}.service${submoduleName!?replace("\\", ".")}.${table.tableAlias}Service;
<#if (table.hasDateColumn)>
import java.util.Date;
</#if>
<#if (table.hasBigDecimalColumn)>
import java.math.BigDecimal;
</#if>

/**
 * <p>${table.tableAlias} 模块ctrol </p>
 *
 * @since ${.now}
 */
@Controller
@RequestMapping("${table.tableAlias?lower_case}") 
public class ${table.tableAlias}Controller {
	
	@Autowired
	private ${table.tableAlias}Service ${table.tableAlias?uncap_first}Service;
	
	@RequestMapping(method = RequestMethod.GET)
	public String index(Model model ) {
		return "${table.tableAlias?lower_case}/index";
	}
	
	@RequestMapping(value = "ajax/add")
	@ResponseBody
	public void add( ${table.tableAlias} bean ) {
		${table.tableAlias?uncap_first}Service.insert( bean );
	}
	
	@RequestMapping(value = "ajax/delete")
	@ResponseBody
	public void delete( <#list table.primaryKeys as key>${key.javaType} ${key.javaProperty} </#list>) {
		${table.tableAlias?uncap_first}Service.delete( <#list table.primaryKeys as key> ${key.javaProperty} </#list> );
	}
	
	@RequestMapping(value = "ajax/update")
	@ResponseBody
	public void update( ${table.tableAlias} bean ) {
		${table.tableAlias?uncap_first}Service.update( bean );
	}
	
	@RequestMapping(value = "ajax/getList")
	@ResponseBody
	public Map<String, Object> getList( ${table.tableAlias} bean ) {
		List<${table.tableAlias} > list = ${table.tableAlias?uncap_first}Service.getList( bean );
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("rows", list );
		return map;
	}
	
	@RequestMapping(value = "ajax/getOne")
	@ResponseBody
	public Map<String, Object> getOne( <#list table.primaryKeys as key> ${key.javaType} ${key.javaProperty} </#list> ) {
		${table.tableAlias} result = ${table.tableAlias?uncap_first}Service.findByPk( <#list table.primaryKeys as key> ${key.javaProperty} </#list> );
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("data", (result == null) ? "" : result );
		return map;
	}
}